          SUBROUTINE (PASSER)
** Version# 32.0002[2] - 10/29/2015 - 09:45am - TSMITH - eclipse
** Copied from CBP PRC.DVR.GP.PREVIEW.B Version# 32.0002[17] - 10/13/2015 - 03:52pm - TSMITH - eclipse
*** V32.0002 Change - Custom Coding . - 10/29/2015 - TSMITH - eclipse
** Copied from CBP PRC.DVR.GP.PREVIEW Version# 32.0001 - 06/11/2015 - 03:46pm - TSMITH - eclipse
*** V32.0001 Change - Custom Coding . - 06/11/2015 - TSMITH - eclipse

*** Subroutine: PRC.DVR.GP.PREVIEW
*-------------------------------------------------------------------------*
***  Driver for the DETAILED INVOICE GP% REPORT
***  The Detailed Invoice GP% Report lets you create a list of
***  invoices with unusually high or low gross profits, so you
***  can review them and check for errors before actually
***  printing and sending the invoices. Rather than previewing
***  every single invoice, this report allows you to reduce the
***  number of invoices to be previewed to only those most likely
***  to be problems. For example, entries of ten or fifteen
***  points above and below the company average gross profit will
***  reduce the number of invoices to examine significantly. Most
***  errors, in fact, are evidenced by gross profits that are
***  negative or above fifty percent.
*-------------------------------------------------------------------------*
***  PASSER - not used
*-------------------------------------------------------------------------*
*** Common Variables:
*-------------------------------------------------------------------------*
          SCREEN

          * Load hotkeys
          MENU.LOAD  2,19,5,1,'P'
          MENU.LOAD 10,19,4,1,'H'
          MENU.LOAD 17,19,7,1,'O'
          MENU.LOAD 27,19,6,1,'S'

          * Retrieve control record and authorzation settings
          PRC.GP.PREVIEW.INIT AUTHKEYS,CTRL.SETTINGS
          *GP.CONTROL = ""
          *GP.CONTROL<1,1,1> = 100
          *GP.CONTROL<1,1,2> = 0
          GP.CONTROL = CTRL.SETTINGS<1>
          GP.OK      = AUTHKEYS<1,1>
          CT.OK      = AUTHKEYS<2,1>

          SD       = ''
          ED       = ''
          FITEM    = ''
          COST.LIST= ''

          IF CT.OK THEN COST.LIST<1,-1> = 'Generic Cost'
          IF GP.OK THEN COST.LIST<1,-1> = 'Cost of Goods Sold'
          IF CT.OK AND GP.OK THEN COST.LIST<1,-1> = 'Both'
          COST.LIST<1,-1> = 'Both'

          IGN.CPYS  = NO
          COST.TYPE = 'None'
          CONSIGN   = 'Include'
          DRPT$     = 'Invoice GP Preview'
          BATCH     = ''
          BR         = "ALL"
          *BR        = SECURITY<7>                 ; ** User's home branch
          TERR.TYPE = 1

          MIN.GP       = GP.CONTROL<1,1,1>
          MAX.GP       = GP.CONTROL<1,1,2>
          RESTRICT.CHG = GP.CONTROL<1,1,3>

          XFER.OPT     = 'Exclude'
          ORBY         = NO

          PRINT @(15,8):MIN.GP 'R#3'
          PRINT @(34,8):MAX.GP 'R#2'

          SORT.OPT = 'Invoice#'
          SELBY    = 'COGS Cost'
          PSTAT    = ''
          MISC.CHG = 0
          SBR      = 'Shipping Branch'
          SET.STAT = NO

          * Set up our list of Print Statuses...
          PRINT.STATUS  = 'P - Detailed Invoice Preview Queue,'
          PRINT.STATUS := 'Q - Invoice Preview Queue,'
          PRINT.STATUS := 'B - Batch Print,'
          PRINT.STATUS := 'M - Placed on Manifest,'
          PRINT.STATUS := 'H - Held for Printing'

          VERIFY.BR BR,NAME,BRCHS,TERR.TYPE
          PRINT @(15,6):BR 'L#10'
          PRINT @(38,15):'N'
*-------------------------------------------------------------------------*
*** Start Date
INSD:     INP SD,15,3,10,'VD4/'
          IF F12 THEN GOTO FINISH
          IF CHANGED THEN
             IF ED = '' THEN
                ED = SD
                PRINT @(15,4):OCONV(ED,'D4/')
             END
          END
          ON MOVE+1 GOTO INSD,INSD,INSD,INSD,INED,INED
*-------------------------------------------------------------------------*
*** End Date
INED:     INP ED,15,4,10,'VD4/'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INED,INED,INSD,INED,INBATCH,INBATCH
*-------------------------------------------------------------------------*
*** Batch ID
INBATCH:  INP BATCH,15,5,15,'MCU'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INBATCH,INBATCH,INED,INBATCH,INBR,INBR
*-------------------------------------------------------------------------*
*** Selection Branches
INBR:     INP.BR 15,6,10,BR,NAME,BRCHS,TERR.TYPE
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INBR,INBR,INBATCH,INBR,INSBR,INSBR
*-------------------------------------------------------------------------*
*** Select By
INSBR:    INP SBR,15,7,15,V_'D:Shipping Branch':VM:'Pricing Branch'
          IF F12 THEN GOTO FINISH
          IF RESTRICT.CHG THEN
             ON MOVE+1 GOTO INSBR,INSBR,INBR,INSBR,INSORT,INSORT
          END ELSE
             ON MOVE+1 GOTO INSBR,INSBR,INBR,INSBR,INMIN,INMIN
          END
*-------------------------------------------------------------------------*
*** Min GP%
INMIN:    INP MIN.GP,14,8,4,'N'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INMIN,INMIN,INSBR,INMAX,INSORT,INMAX
*-------------------------------------------------------------------------*
*** Max GP%
INMAX:    INP MAX.GP,32,8,4,'N'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INMAX,INMIN,INSBR,INMAX,INSORT,INSORT
*-------------------------------------------------------------------------*
*** Sort By
INSORT:   INP SORT.OPT,15,9,20,V_'D:Time':VM:'Customer':VM:'Invoice#':VM:'Inside Salesperson':VM:'Outside Salesperson':VM:'Writer'
          IF F12 THEN GOTO FINISH
          IF RESTRICT.CHG THEN
             ON MOVE+1 GOTO INSORT,INSORT,INSBR,INSORT
          END ELSE
             ON MOVE+1 GOTO INSORT,INSORT,INMAX,INSORT
          END
*-------------------------------------------------------------------------*
*** Display Costs
INCOST:   INP COST.TYPE,19,10,20,V_'D:':COST.LIST
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INCOST,INCOST,INSORT,INCOST
*-------------------------------------------------------------------------*
*** Display Ordered By
IN.ORBY:  INP ORBY,32,11,1,"YN"
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO IN.ORBY,IN.ORBY,INCOST,IN.ORBY,IN.MISC,IN.MISC
*-------------------------------------------------------------------------*
*** Include Misc Charges
IN.MISC:  INP MISC.CHG,32,12,1,"YN"
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO IN.MISC,IN.MISC,IN.ORBY,IN.MISC,IN.PSTAT,IN.PSTAT
*-------------------------------------------------------------------------*
*** Select Print Status
IN.PSTAT: INP PSTAT,32,13,9,'MCU',V_'*1D:,':PRINT.STATUS
          IF F12 THEN GOTO FINISH
          IF PSTAT<1,1> = "" THEN PSTAT = ""
          IF PSTAT = '' AND SET.STAT THEN
             ERR.MSG  = 'You must enter a Print Status to use':AM
             ERR.MSG := 'the Auto Set Print Status option'
             MESS 1,1,BELL:ERR.MSG
             GOTO IN.PSTAT
          END
          IF NOT(PSTAT) THEN
             SET.STAT = NO
             PRINT @(32,14):'N'
          END
          ON MOVE+1 GOTO IN.PSTAT,IN.PSTAT,IN.MISC,IN.PSTAT,IN.SET,IN.SET
*-------------------------------------------------------------------------*
*** Auto Set Print Status
IN.SET:   INP SET.STAT,32,14,1,'YN'
          IF F12 THEN GOTO FINISH
          IF SET.STAT AND CHANGED THEN
             IF NOT(PSTAT) THEN
                ERR.MSG  = 'You must enter a Print Status to use':AM
                ERR.MSG := 'the Auto Set Print Status option'
                MESS 1,1,BELL:ERR.MSG
                SET.STAT = NO
                PRINT @(32,14):'Y'
                GOTO IN.SET
             END
          END
          IF NOT(SET.STAT) THEN
             PRINT @(38,15):'Y'
             ING.CPYS = NO
          END
          ON MOVE+1 GOTO IN.SET,IN.SET,IN.PSTAT,IN.SET
*-------------------------------------------------------------------------*
*** Ignore the number of invoice copies to print when the automatic status
*** change is used.
IN.IGPC:  INP IGN.CPYS,38,15,1,'YN'
          IF F12 THEN GOTO FINISH
          IF SET.STAT = NO OR SET.STAT = '' THEN
             IGN.CPYS = NO
             PRINT @(38,15):'N'
          END
          ON MOVE+1 GOTO IN.IGPC,IN.IGPC,IN.SET,IN.IGPC,INCONS
*-------------------------------------------------------------------------*
*** Include/Exclude/Only Consignment Transfers
INCONS:   INP CONSIGN,41,16,7,V_'D:Include':VM:'Exclude':VM:'Only'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INCONS,INCONS,IN.IGPC,INCONS
*-------------------------------------------------------------------------*
*** Include/Exclude/Only Transfers
INXFER:   INP XFER.OPT,41,17,7,V_'D:Include':VM:'Exclude':VM:'Only'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INXFER,INXFER,INCONS,INXFER,INXFER,INXFER
*-------------------------------------------------------------------------*
SUBS:     IF OPTION = 4 THEN GOTO FSEL
          IF NUM(SD) AND NUM(ED) THEN
             IF SD > ED THEN
                ERR.MESS 1,1,BELL:' Start date must be before end date'
                RETURN TO INSD
             END
          END

          IF BRCHS = ''      THEN PRINT BELL:;  RETURN TO INBR
          *IF MIN.GP > MAX.GP THEN PRINT BELL:;  RETURN TO INMIN
          IF SORT.OPT  = ''  THEN PRINT BELL:;  RETURN TO INSORT
          IF COST.TYPE = ''  THEN PRINT BELL:;  RETURN TO INCOST

          IF NOT(PSTAT) AND SET.STAT THEN
             ERR.MSG  = 'You must enter a Print Status to use':AM
             ERR.MSG := 'the Auto Set Print Status option'
             MESS 1,1,BELL:ERR.MSG
             RETURN TO IN.PSTAT
          END

          ADDL.DATA = SET.STAT:'~':CONSIGN:'~':XFER.OPT:'~':IGN.CPYS
          PH.SETUP.BR.ARGS BR,,TERR.TYPE,,BRDISP,BRLIST
          PH.EXE 'PRC.PHR.GP.PREVIEW',SD,ED,BATCH,BRLIST,BRDISP,MIN.GP,MAX.GP,SORT.OPT,ORBY,COST.TYPE,MISC.CHG,PSTAT,SBR,FITEM,ADDL.DATA
          IF F12 THEN RETURN
          RETURN TO FINISH
*-------------------------------------------------------------------------*
FSEL:     FILTER.INPUT 'S',FITEM
          RETURN
*-------------------------------------------------------------------------*
FINISH:   WINDOW.CLOSE
          RETURN
*-------------------------------------------------------------------------*
!TSMITH~10/29/15~09:45
